import request from "@/utils/http/axios/Axios.ts";
import {addAttrValue, attrListResp, attrResp, categoryResp} from "@/api/product/attr/type.ts";


enum API {
    CATEGORY_ONE_URL = '/admin/product/getCategory1',
    CATEGORY_TWO_URL = '/admin/product/getCategory2',
    CATEGORY_THREE_URL = '/admin/product/getCategory3',
    ATTR_DETAIL_LIST_URL = '/admin/product/attrInfoList',
    ATTR_DELETE_URL = '/admin/product/deleteAttr',
    ATTR_ADD_OR_UPDATE_URL = '/admin/product/saveAttrInfo',
}


export const getCategoryOne = () => request.get<any, categoryResp>(API.CATEGORY_ONE_URL)
export const getCategoryTwo = (categoryOneId: number | string) => request.get<any, categoryResp>(API.CATEGORY_TWO_URL + `/${categoryOneId}`)
export const getCategoryThree = (categoryTwoId: number | string) => request.get<any, categoryResp>(API.CATEGORY_THREE_URL + `/${categoryTwoId}`)
export const getAttrInfoList = (categoryOneId: number | string, categoryTwoId: number | string, categoryThreeId: number | string) => request.get<any, attrListResp>(API.ATTR_DETAIL_LIST_URL + `/${categoryOneId}/${categoryTwoId}/${categoryThreeId}`)
export const deleteAttrInfo = (id: number) => request.delete<any, attrResp>(API.ATTR_DELETE_URL + `/${id}`)
export const addAttrInfo = (date: addAttrValue) => request.post<any, attrResp>(API.ATTR_ADD_OR_UPDATE_URL, date)
